﻿using System;
using System.Globalization;
using Avalonia.Data.Converters;
using FluentAvalonia.UI.Controls;

namespace MusicFluent.Converters;

public class PlayConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is string s)
        {
            if (string.IsNullOrEmpty(s)) return value;

            if (s == "Single Loop") s = "RepeatAll";

            if (s == "List") s = "BulletList";

            if (s == "Random") s = "Shuffle";

            if (s == "Single") s = "Forward";

            return Enum.Parse<Symbol>(s);
        }
        return value;
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return value;
    }
}